package com.lanhao.aot.excel;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;

import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;
import com.lanhao.aot.util.BigDecimalUtil;

import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;

public class ExcelParseUtil2 {
	
	private static SimpleDateFormat sdf = new SimpleDateFormat("ssSSS");
	public static String getRandomNo(String prefix) {
		String nextInt = String.valueOf(new Random().nextInt(100));
		if(nextInt.length() < 2) {
			nextInt = "0" + nextInt;
		}
		return prefix + sdf.format(new Date()) + nextInt;
	}
	
	
	public static void main(String[] args) {
		ExcelReader reader = ExcelUtil.getReader("D://附加费明细-202405月.xlsx", 0);
		List<List<Object>> readAll = reader.read();
		JSONArray array = new JSONArray();
		
		for (int i = 1; i < readAll.size(); i++) {
			System.out.println("第" + i + "行数据处理中");
			List<Object> lineList = readAll.get(i);
			String orderNo = (String) lineList.get(2);
			String bizNo = (String) lineList.get(3);
//			Double rate = (Double) lineList.get(9);
			Double otherFee = (Double) lineList.get(10);
			JSONObject o = new JSONObject();
			o.put("orderNo", orderNo);
			o.put("businessNo", bizNo);
			o.put("newFuelAdditionalRate", BigDecimalUtil.ZERO);
//			o.put("newFuelAdditionalRate", BigDecimalUtil.getBigDecimal(BigDecimalUtil.getBigDecimal(String.valueOf(rate * 100))));
//			o.put("newFuelAdditionalRate", String.valueOf((Double.valueOf(rate) * 100)));
			o.put("newOtherFee", BigDecimalUtil.getBigDecimal(BigDecimalUtil.getBigDecimal(String.valueOf(otherFee))));
			array.add(o);
//			String respBody = HttpRequest.post("http://shipment.anhelogistics.com/smt-integration/inner/doAttachmentfeeSync").body(array.toString()).execute().body();
//			respList.add("[" + bizNo + "]" + respBody);
		}
		
		try {
			FileUtils.write(new File("D:/sync_json_202405.txt"), array.toString(), "UTF-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
        
	}
	
}
